<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>all categories  page</title>
    </h:head>
    <h:body>
        <ui:composition template="../Master/adminMaster.xhtml">
            <ui:define name="page-content">

                <section class="grid_12" id="dashtabs">
                    <div class="box-header">
                        Categories Manager
                        <ul class="controls"></ul>
                    </div>
                    <div id="dashtabs-pages" class="box-content no-padding">

                        <h:form id="form">

                            <p:growl id="messages" showDetail="true"/>

                            <p:dataTable var="ca" value="#{categoryMBean.categories}" id="categoriesList" editable="true"
                                         paginator="true" rows="10" 
                                         paginatorPosition="bottom"
                                         rowsPerPageTemplate="5,10,15" styleClass="table no-border"
                                         emptyMessage="No article found with given criteria" filteredValue="#{categoryMBean.filteredCategories}"
                                         widgetVar="categoriesTable" rowKey="#{ca.categoryID}">

                                <f:facet name="header">  
                                    <p:outputPanel style="float: right;">  
                                        <h:outputText value="Search all fields:" />  
                                        <p:inputText id="globalFilter" onkeyup="categoriesTable.filter()" style="width:150px" />  
                                    </p:outputPanel>  
                                </f:facet>

                                <p:column headerText="Name">
                                    <h:outputText value="#{ca.categoryName}"/>
                                </p:column>
                                <p:column headerText="Priority">
                                    <h:outputText value="#{ca.categoryPriority}"/>
                                </p:column>
                                <p:column headerText="Options" style="width:100px !important;">
                                    <p:commandLink id="editCategory" title="Edit"
                                                   action="#{categoryMBean.actionEditCategory(ca)}">   
                                        <p:graphicImage value="../CSS/images/pencil.png"></p:graphicImage>
                                    </p:commandLink>
                                    <h:panelGroup rendered="#{login.customer.membersRole == 2}">
                                        <p:commandLink id="showDialogButton" onclick="confirmation.show()"
                                                       title="Remove" update=":form:display">
                                            <p:graphicImage value="../CSS/images/cross_circle.png" alt=""></p:graphicImage>
                                            <f:setPropertyActionListener value="#{ca}" 
                                                                         target="#{categoryMBean.selectedCategory}" />
                                        </p:commandLink> 
                                    </h:panelGroup>
                                </p:column>

                            </p:dataTable>

                            <p:confirmDialog id="confirmDialog" message="Are you sure about remove this category?"  
                                             header="Initiating destroy process" 
                                             severity="alert" widgetVar="confirmation">  
                                <h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">  

                                    <p:commandButton id="confirm" value="Yes Sure" update=":form:messages,:form:categoriesList" 
                                                     oncomplete="confirmation.hide()"  
                                                     actionListener="#{categoryMBean.removeCategory}">
                                    </p:commandButton>
                                    <p:commandButton id="decline" value="Not Yet" onclick="confirmation.hide()" type="button" />

                                </h:panelGrid>  
                            </p:confirmDialog>

                        </h:form>

                    </div>
                </section>
                <br class="cl" />
            </ui:define>
        </ui:composition>
    </h:body>
</html>

